Summary

Row

confirmed

1193078 (+ 45720 )

recovered

753050 (+ 29557 )

death

28732 (+ 1129 )

Row

About

This is a simple project to create a dashboard with few calculations and representations for current COVID-19 pandemic and its affect on India.

Current Data Source: https://pomber.github.io/covid19/

This site auto updates in every 12 hours.

Project Source Code: https://github.com/sk-sahu/covid19-dashboard

---
title: "COVID-19 India Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
    vertical_layout: fill
---


```{r setup, include=FALSE}
library(flexdashboard)
library(jsonlite)
library(dplyr)
library(magrittr)
library(DT)
library(dygraphs)
library(tbl2xts)
library(lubridate)
```

```{r get_data}
url <- "https://pomber.github.io/covid19/timeseries.json"
covid19_data <- fromJSON(url)
```

```{r colors_set}
confirmed_color <- "purple"
active_color <- "#1f77b4"
recovered_color <- "forestgreen"
death_color <- "red"
```

```{r func_def}
# takes a dataframe covid19_data$India
total_confirmed <- function(data){
  tail(data$confirmed, n = 2)[-2]
}
new_confirmed <- function(data){
  tail(data$confirmed, n=1) - tail(data$confirmed, n=2)[-2]
}
total_deaths <- function(data){
  tail(data$deaths, n = 2)[-2]
}
new_deaths <- function(data){
  tail(data$deaths, n=1) - tail(data$deaths, n=2)[-2]
}
total_recovered <- function(data){
  tail(data$recovered, n = 2)[-2]
}
new_recovered <- function(data){
  tail(data$recovered, n=1) - tail(data$recovered, n=2)[-2]
}

total_table <- function(data){
  all <- c(total_confirmed(data), total_deaths(data), total_recovered(data))
  table <- data.frame(all, row.names = c("Confirmed", "Deaths", "Recovered"))
  names(table) <- "Total Numbers"
  return(table)
}  

```


Summary
=======================================================================
Row
-----------------------------------------------------------------------

### confirmed {.value-box}

```{r}
valueBox(value = paste(total_confirmed(covid19_data$India), 
                       "(+",new_confirmed(covid19_data$India), ")"), 
         caption = paste("Total Confirmed Cases", "(Last Update: ",tail(covid19_data$India, n=1)$date, ")"), 
         icon = "fas fa-user-md", 
         color = confirmed_color)
```


### recovered {.value-box}

```{r}
valueBox(value = paste(total_recovered(covid19_data$India),
                       "(+",new_recovered(covid19_data$India), ")"), 
         caption = "Recovered Cases", icon = "fas fa-heartbeat", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(total_deaths(covid19_data$India),
                       "(+",new_deaths(covid19_data$India), ")"), 
         caption = "Death Cases", 
         icon = "fas fa-heart-broken", 
         color = death_color)
```

Row
-----------------------------------------------------------------------

```{r india}
#total_table(covid19_data$India) %>% DT::datatable()

t_data <- covid19_data$India %>% 
  select(date, confirmed, recovered, deaths) %>% 
  mutate(date =  lubridate::date(date)) %>% 
  tbl_xts(.)

dygraph(data = log10(t_data), main = "Covid India Curve", ylab = "log10(Numbers)") %>%
  dyRangeSelector() %>% 
  dyOptions(stackedGraph = TRUE, 
            colors = c(confirmed_color, recovered_color, death_color))

```


About
=======================================================================

This is a simple project to create a dashboard with few calculations and representations for current COVID-19 pandemic and its affect on India.

Current Data Source: https://pomber.github.io/covid19/

**This site auto updates in every 12 hours.**

Project Source Code: https://github.com/sk-sahu/covid19-dashboard